#include "MyGLApp.h"

namespace mp_myApp
{

	MyGLApp::MyGLApp(GlConsole* console)
		:GLApp(console)
	{
		//Create Scenes
		m_drawTest = new MyTestScene();
		this->LoadScene(m_drawTest);
		//m_netServer = new NetworkServer();
		//m_netClient = new NetworkClient();
	}

	MyGLApp::~MyGLApp()
	{
		UnloadCurrentScene();
		delete m_drawTest;
		m_drawTest = NULL;
	}

	void MyGLApp::testFcnX()
	{
		int x = 1;
		while (x < 100)
		{
			x += x;
			if (x > 10000)
				x = 1;
		}
	}

	void MyGLApp::Initialize()
	{

		//NOTE: This function should setup any properties and
		//			settings for all the components to be initialized

		//Create the GLWindow
		m_ac->m_glWindow->CreateGLWindow(1024, 768, "Mitchell's OpenGL Test", NULL, NULL);
		m_ac->m_glWindow->MakeContextCurrent();

		//Setup GLInput Manager
		m_ac->m_glInput->SetWindow(m_ac->m_glWindow->GetWindow());

		//Setup Audio Manager

		//Setup Network Manager ---
		/*m_ac->m_network->SetServerSession(m_netServer);
		m_ac->m_network->SetClientSession(m_netClient);
		m_ac->m_network->Run();*/
		GLApp::Initialize();
		
	}

	void MyGLApp::LoadContent()
	{
		GLApp::LoadContent();
	}

	void MyGLApp::Uninitialize()
	{
		GLApp::Uninitialize();

	}

	void MyGLApp::Update()
	{
		//pre scene update

		//### DO LOGIC ###
		//m_ac->m_glInput->Update();

		//if (m_quitEvent->IsTriggered())
		//	m_running = false;

		//Updates the scene
		GLApp::Update();

		//post scene update

	}

	void MyGLApp::Draw()
	{
		//pre scene rendering

		//Draws the scene
		GLApp::Draw();

		//post scene rendering
	}

	/*!
	* @Note: Can run on separate thread.
	*/
	void MyGLApp::UpdateLogic()
	{
		//pre scene logic

		//Updates scene logic
		GLApp::UpdateLogic();

		//post scene logic
	}
}